
#-----------------------Parametros-----------------------------------------------------------------------------

param proveedor; 																			
param planta;																					
param retailer;																				

param costoSilla{p in 1..planta};
param capacidadMinima{p in 1..planta};
param capacidadMaxima{p in 1..planta};

param costoMadera{i in 1..proveedor};
param compraMinima{i in 1..proveedor};

param costoTransporteMadera{i in 1..proveedor,p in 1..planta};
param costoTransporteSilla{p in 1..planta,r in 1..retailer};

param precioVenta{r in 1..retailer};
param demandaMaxima{r in 1..retailer};
param demandaMinima{r in 1..retailer};

param costoFijo{p in 1..planta};

#-----------------------Variables-----------------------------------------------------------------------------

var maderaComprada{i in 1..proveedor, p in 1..planta}>=0;
var sillasVendidas{p in 1..planta, r in 1..retailer}>=0;

var producePlanta{p in 1..planta} binary;

#-----------------------Funcion Objetivo----------------------------------------------------------------------

maximize Profit:
	sum{p in 1..planta,r in 1..retailer} precioVenta[r] * sillasVendidas[p,r]
	- sum{i in 1..proveedor, p in 1..planta} costoMadera[i]*maderaComprada[i,p]
	- sum{i in 1..proveedor, p in 1..planta} costoTransporteMadera[i,p]*maderaComprada[i,p]
	- sum{p in 1..planta,r in 1..retailer} costoTransporteSilla[p,r]*sillasVendidas[p,r]
	- sum{p in 1..planta,r in 1..retailer} costoSilla[p]*sillasVendidas[p,r]
	- sum{p in 1..planta} producePlanta[p]*costoFijo[p];                 
	

#-----------------------Restricciones-------------------------------------------------------------------------
	
subject to demandaMax {r in 1..retailer}:
	sum{p in 1..planta} sillasVendidas[p,r] >= demandaMinima[r];
subject to demandaMin {r in 1..retailer}:
	sum{p in 1..planta} sillasVendidas[p,r] <= demandaMaxima[r];	
subject to capacidadMax{p in 1..planta}:
	sum{r in 1..retailer} sillasVendidas[p,r] >= capacidadMinima[p]*producePlanta[p];   
subject to capacidadMin{p in 1..planta}:
	sum{r in 1..retailer} sillasVendidas[p,r] <= capacidadMaxima[p]*producePlanta[p];
subject to demandaMin2{i in 1..proveedor}:
	sum{p in 1..planta} maderaComprada[i,p] = compraMinima[i];
subject to materiales{p in 1..planta}:
	sum{i in 1..proveedor} maderaComprada[i,p] = sum{r in 1..retailer} sillasVendidas[p,r]*12;
subject to sillasPositivas{p in 1..planta, r in 1..retailer}:
	sillasVendidas[p,r] >= 0;
subject to maderasPositivas{i in 1..proveedor, p in 1..planta}:
	maderaComprada[i,p] >= 0;
subject to defineProducePlanta:
        sum{p in (planta-2)..planta} producePlanta[p]=1;						
subject to plantasFijas{p in 1..(planta-2)}:                                   
        producePlanta[p]=1;
subject to noProduce{i in 1..proveedor, p in (planta-2)..planta}:                      
        maderaComprada[i,p]<=90000000*producePlanta[p];


        